/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.com.mblj.domain;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "region")
@NamedQueries({@NamedQuery(name = "Region.findAll", query = "SELECT r FROM Region r"), @NamedQuery(name = "Region.findByRgRegion", query = "SELECT r FROM Region r WHERE r.rgRegion = :rgRegion"), @NamedQuery(name = "Region.findByRgDescripcion", query = "SELECT r FROM Region r WHERE r.rgDescripcion = :rgDescripcion")})
public class Region implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "rg_region")
    private Integer rgRegion;
    @Column(name = "rg_descripcion")
    private String rgDescripcion;
    @JoinColumn(name = "dp_departamento", referencedColumnName = "dp_departamento")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Departamentos dpDepartamento;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rgRegion", fetch = FetchType.LAZY)
    private List<Paises> paisesList;

    public Region() {
    }

    public Region(Integer rgRegion) {
        this.rgRegion = rgRegion;
    }

    public Integer getRgRegion() {
        return rgRegion;
    }

    public void setRgRegion(Integer rgRegion) {
        this.rgRegion = rgRegion;
    }

    public String getRgDescripcion() {
        return rgDescripcion;
    }

    public void setRgDescripcion(String rgDescripcion) {
        this.rgDescripcion = rgDescripcion;
    }

    public Departamentos getDpDepartamento() {
        return dpDepartamento;
    }

    public void setDpDepartamento(Departamentos dpDepartamento) {
        this.dpDepartamento = dpDepartamento;
    }

    public List<Paises> getPaisesList() {
        return paisesList;
    }

    public void setPaisesList(List<Paises> paisesList) {
        this.paisesList = paisesList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rgRegion != null ? rgRegion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Region)) {
            return false;
        }
        Region other = (Region) object;
        if ((this.rgRegion == null && other.rgRegion != null) || (this.rgRegion != null && !this.rgRegion.equals(other.rgRegion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.mblj.domain.Region[rgRegion=" + rgRegion + "]";
    }

}
